﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace Converter
{
    public class BoolToHiddenConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                bool bl = bool.Parse(value.ToString());

                if (parameter == null)
                {
                    if (bl)
                    {
                        return Visibility.Visible;
                    }
                    else
                    {
                        return Visibility.Hidden;
                    }
                }
                else
                {
                    var para = parameter.ToString();
                    if (para == "false")
                    {
                        if (!bl)
                        {
                            return Visibility.Visible;
                        }
                        else
                        {
                            return Visibility.Hidden;
                        }
                    }
                    return Visibility.Hidden;
                }
            }
            catch (Exception)
            {
                return Visibility.Hidden;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
